(function ({form,layer,SelectDatas,formdata, vstaffid, url, ok, AjaxFn}) {

    formdata = AjaxFn(url+'selStaffByStaffid', JSON.stringify({vstaffid}), formdata),

    (()=>(
        res = AjaxFn(url + "staffSelectDatas", "", {}),
            {positions,teams,factorys,appraises,code,msg,option=''} = res,
            positions.length>0?($.each(positions,(i,v)=>(option+=`<option value="${v.vpositionid}">${v.vpositionname}</option>`)),$("select[name=vpositionid]").html(option)):$("select[name=vpositionid]").html('<option value=""></option>'),
            teams.length>0?(option='',$.each(teams,(i,v)=>(option+=`<option value="${v.vteamid}">${v.vteamname}</option>`)),$("select[name=vteamid]").html(option)):$("select[name=vteamid]").html('<option value=""></option>'),
            factorys.length>0?(option='',$.each(factorys,(i,v)=>(option+=`<option value="${v.scode}">${v.vname}</option>`)),$("select[name=vfactoryflg]").html(option)):$("select[name=vfactoryflg]").html('<option value=""></option>'),
            appraises.length>0?(option='',$.each(appraises,(i,v)=>(option+=`<input type="radio" disabled name="vappraiseflg" lay-filter="vappraiseflg" value="${v.scode}" title="${v.vname}">`)),
            $("#vappraiseflgRadio").append(option)):"", SelectDatas=res)
    )(),

    form.val("staffUpdataForm",formdata.staff),form.render(),

    form.on('select(vteamid)',  ({elem, value, othis}) => (team = SelectDatas.teams.findIndex(v => v.vteamid == value), $("select[name=vfactoryflg]").val(SelectDatas.teams[team].vfactoryflg), form.render('select'), $(`input[name=vappraiseflg]`).attr('checked', false), $(`input[name=vappraiseflg][title=${SelectDatas.teams[team].vappraiseflgname}]`).prop('checked', true), form.render('radio'))),

    form.on("submit",function ({field,res}) {
        res = AjaxFn (url+"StaffByStaffid", JSON.stringify(field), {}),{code,msg}=res, code==200?ok(msg,1):layer.msg(msg,{icon: 5})
        return false;
    })
})({
    form: layui.form,
    table: layui.table,
    layer: layui.layer,
    laydate: layui.laydate,
    SelectDatas: {},
    url: "/evaluation/staff/",
    formdata :{},
    vstaffid:$("input[name=vstaffid]").val(),
    contentType: 'application/json;charset=utf-8',
    ok: function (msg, icon) {
        layui.layer.confirm(msg, {
            id: "ok",
            icon: icon,
            anim: 4,
            title: '提示',
            btn: ['确定'],
            closeBtn: false,
            success: function (layero) {
                var btn = layero[0].getElementsByClassName('layui-layer-btn')[0].getElementsByTagName('A')[0];
                btn.href = 'javascript:void(0)';
                btn.focus();
            },
            yes: function (index, layero) {
                layer.close(index); //再执行关闭
            },
            end: function () {
                var index2 = parent.layer.getFrameIndex(window.name);
                parent.layer.closeAll();
            }
        });
    },
    AjaxFn: function (url, data, resource) {
        $.ajax({
            url,
            contentType: 'application/json;charset=utf-8',
            type: 'post',
            async: false,
            data,
            success: function (res) {
                let {msg='',code=''} =res;
                msg=='' && code==''? top.location.reload() : "";
                resource = res;
            }
        });
        return resource;
    },
})